<?php

  require_once('./includes/db.php');
  $msg = '';

  $_POST['lang'] = implode(',',$_POST['lang']);
  $_POST['hobbies'] = implode(',',$_POST['hobbies']);

  $_POST = arrayCleanup($_POST);

  pr1($_POST);
  pr1($_FILES);
  ######################################
if($_FILES['u_avatar']['error']!= 4)
{
  $uploadResult = upload('u_avatar','./uploads',array('jpg','jpeg','png'),1.0);
  pr($uploadResult);

  unlink('./uploads/'.$_POST['avatar']);
  unlink('./uploads/chats/'.$_POST['avatar']);
  unlink('./uploads/wall/'.$_POST['avatar']);

  $_POST['avatar'] = $uploadResult['fileName'];
  #####################################
    ini_set('memory_limit', '-1');

    $imageName = $uploadResult['fileName'];
    $thumbSrc = "./uploads/$imageName";
    /*** Start Create Dir if not exists***/
   if(!is_dir('./uploads/chat')){
     mkdir("./uploads/chat");
   }
   if(!is_dir('./uploads/wall')){
     mkdir("./uploads/wall");
   }
    /*** End Create Dir if not exists***/
    // include image processing code
    require_once('./thumb/image.class.php');
    $img = new Zubrag_image;
    $img->max_x        = 100;
    $img->max_y        = 70;
    $img->GenerateThumbFile
    ($thumbSrc, "./uploads/wall/$imageName");//700/50

    $img = new Zubrag_image;
    $img->max_x        = 50;
    $img->max_y        = 20;
    $img->GenerateThumbFile
    ($thumbSrc, "./uploads/chat/$imageName");
}// check uploaded or not

  #####################################

  $id = $_POST['id'];

  $isUpdated = updateById('users',$id,$_POST);

  header("location:show_all_users.php");
  exit;

  //var_dump($isUpdated);
  //echo "Record UPdated on id $id";
//require_once('./includes/footer.php');

